/*******************************************************************************
 * Package: com.song.kkxxpoi.controller
 * Type:    Web
 * Date:    2022-05-02 16:08
 *
 *
 *
 * You may not use this file except in compliance with the License.
 *******************************************************************************/
package com.song.kkxxpoi.controller;

import com.song.common.annotation.ResponseInfoSkin;
import com.song.kkxxpoi.entity.IntEndScaleForecastEntity;
import com.song.kkxxpoi.mapper.IIntEndScaleForecastMapper;
import com.song.kkxxpoi.service.TransactionalEnd;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 功能描述：调试mybaits或者事务
 *
 * @author Songxianyang
 * @date 2022-05-02 16:08
 */
@Api(tags = "调试源码")
@RestController
@RequestMapping("/baits/test")
@Slf4j
@ResponseInfoSkin
public class MyabtisWeb {
    @Resource
    private SqlSessionFactory sqlSessionFactory;
    @Resource
    private TransactionalEnd transactionalEnd;


    @GetMapping("/get-1")
    @ApiOperation("获取详情原始写法：调试 @Mapper 代码执行源码")
    public IntEndScaleForecastEntity get1(@RequestParam String id) {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        IIntEndScaleForecastMapper mapper = sqlSession.getMapper(IIntEndScaleForecastMapper.class);
        IntEndScaleForecastEntity byId = mapper.getById(id);
        return byId;
    }


    /**
     * 调试事务源码
     */
    @GetMapping("/transactionalEnd-1")
    @ApiOperation("调试事务")
    public void transactionalEndGet1(@RequestParam String id) {
        transactionalEnd.main();
    }

}
